import { defineStore } from 'pinia'
import { game1, game2, game3, game4, game5, game6, game7, game8, game9 } from '@/assets/images'
import dayjs from 'dayjs'
// 你可以任意命名 `defineStore()` 的返回值，但最好使用 store 的名字，同时以 `use` 开头且以 `Store` 结尾。
// (比如 `useUserStore`，`useCartStore`，`useProductStore`)
// 第一个参数是你的应用中 Store 的唯一 ID。
const time = dayjs().format('YYYY-MM-DD')

export const useStore = defineStore('user', {
  // 其他配置...
  state: () => {
    return { 
      logined: false,
      loginVisiable:false ,
      homeList:[
        {
          src: game1,
          time,
          title: "一起玩，上车走",
          people: "1/2",
          mail: "329106955@qq.com",
        },
        {
          src: game2,
          time,
          title: "开黑五等四",
          people: "2/5",
          mail: "450126954@qq.com",
          
        },
        {
          src: game3,
          time,
          title: "3缺1,匹配速刷",
          people: "2/4",
          mail: "hunmm@163.com",
          
        },
        {
          src: game4,
          time,
          title: "双排速度来人",
          people: "1/2",
          mail: "wuxggg@163.com",
          
        },
        {
          src: game5,
          time,
          title: "三排，速战速决",
          people: "2/3",
          mail: "456345567@hotmail.com",
          
        },
        {
          src: game6,
          time,
          title: "国服打野,在线等",
          people: "2/4",
          mail: "penghao111@163.com",
          
        },
        {
          src: game7,
          time,
          title: "国服打野带飞",
          people: "3/4",
          mail: "wuzhangwang@qq.com",
          
        },
      ],
      chatList: [
        {
          title: "输麻了,来个人",
          content: "来个人拯救一下",
          image: game2,
        },
        {
          title: "野王在线",
          content: "归龙潮",
          image: game8
        },
        {
          title: "三等一",
          content: "包赢的，差你一人",
          image: game9
        },
      ]
    }
  },
  actions: {
    login() {
      this.logined = true
    },
    loginout() {
        this.logined = false
    },
    loginVisiableShow() {
      this.loginVisiable = true
    },
    loginVisiableDismiss() {
      this.loginVisiable = false
    },
    removeHomeIndex(mail){
      // this.homeList.splice(index,1)
      this.homeList = this.homeList.filter((item)=> {
        return item.mail !== mail
      });
    },
    removeChatList(title){
      this.chatList = this.chatList.filter((item)=> {
        return item.title !== title
      });
      console.log(this.chatList);
      
    }
  },
})